<form class="form-horizontal" id="form-edit-article">


    <div class="form-group">
        <label class="control-label col-xs-2">
            新闻分类
            <span style="color: #FF0000;">*</span>
        </label>
        <div class="col-xs-9">
            <select id="category-selector" name="cid" class="form-control" tabindex="-1" required>
                <option value="">
                    无选择
                </option>
                {volist name="category_list" id="item"}
                <option value="{$item.id}" {if condition="$article.category_id==$item.id"}selected{/if}>{$item.title}</option>
                {/volist}
            </select>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-2">
            新闻标签
            <span style="color: #FF0000;">*</span>
        </label>
        <div class="col-xs-9">
            <select id="tag-selector" name="tag_id" class="form-control" tabindex="-1" required>
                <option value="">
                    无选择
                </option>
                {volist name="tag_list" id="item" key="itk"}
                <option value="{$itk}" {if condition="$article.tag_id==$itk"}selected{/if}>{$item}</option>
                {/volist}
            </select>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-2">
            新闻标题
            <span style="color: #FF0000;">*</span>
        </label>
        <div class="col-xs-9">
            <input type="text" class="form-control" name="title" value="{$article.title}"
                   placeholder="请输入新闻标题" required>
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-2">
            缩略图
        </label>
        <div class="col-xs-9">
            {include file="public/singleImageUploader" uploader-name="thumb" /}
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-2">
            新闻简介
        </label>
        <div class="col-xs-9">
            <textarea class="form-control" name="desc" rows="3"
                      placeholder="请输入新闻简介">{$article.description}</textarea>
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-2">
            排序
        </label>
        <div class="col-xs-9">
            <input type="number" class="form-control" name="order"  value="{$article.display_order}"
                   placeholder="数字越大 排序越靠前">
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-2">
            浏览量
        </label>
        <div class="col-xs-9">
            <input type="number" class="form-control" name="view_num" value="{$article.view_num}"
                   placeholder="新闻浏览量">
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-2">
            是否显示
        </label>
        <div class="col-xs-9">
            <div class="btn-group" data-toggle="buttons">
                <label class="btn btn-default {if condition='$article.is_visible'}active{/if}">
                    <input type="radio" name="visible" id="visible_1" value="1" {if condition="$article.is_visible"}checked{/if}>
                    显示
                </label>
                <label class="btn btn-default {if condition='!$article.is_visible'}active{/if}">
                    <input type="radio" name="visible" id="visible_0" value="0" {if condition="!$article.is_visible"}checked{/if}>
                    隐藏
                </label>
            </div>
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-2">
            首页推荐
        </label>
        <div class="col-xs-9">
            <div class="btn-group" data-toggle="buttons">
                <label class="btn btn-default {if condition='$article.is_recommend'}active{/if}">
                    <input type="radio" name="recommend" id="recommend_1" value="1" {if condition="$article.is_recommend"}checked{/if}>
                    推荐
                </label>
                <label class="btn btn-default {if condition='!$article.is_recommend'}active{/if}">
                    <input type="radio" name="recommend" id="recommend_0" value="0" {if condition="!$article.is_recommend"}checked{/if}>
                    不推荐
                </label>
            </div>
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-2">
            新闻详情
        </label>
        <div class="col-xs-9">
            {include file="public/ueditor" editor-name="article_detail" /}
        </div>
    </div>

    <div class="form-group">
        <div class="col-xs-offset-2 col-xs-3">
            <button type="button" class="btn btn-success btn-block" onclick="ajaxSubmit('form-edit-article', true)">
                编辑
            </button>
        </div>
    </div>
</form>

<script src="__PUBLIC__/vendors/jquery.validation/jquery.validate.min.js"></script>
<script src="__PUBLIC__/vendors/jquery.validation/additional-methods.js"></script>
<script src="__PUBLIC__/vendors/jquery.validation/messages_zh.min.js"></script>
<script src="__PUBLIC__/vendors/select2/js/select2.min.js"></script>
<script type="application/javascript">
    $(function () {
        $("#form-edit-article").validate({
            messages:
                {
                    cid: "请选择新闻分类",
                    title: "请输入新闻标题",
                    tag_id:'请选择新闻标签'
                },
            debug: true,
            submitHandler: function () {
                ajaxSubmit('form-edit-article', true);
            }
        });

        //获取分类
        $("#category-selector").select2({
            placeholder: "选择新闻分类",
            allowClear: true,
            width:'100%'
        });
        $("#tag-selector").select2({
            placeholder: "选择新闻标签",
            allowClear: true,
            width:'100%'
        });
    })
</script>